package controls;

import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import com.jme3.scene.control.Control;

import eventManager.EventManager;

public class CameraLODControl extends AbstractControl {

	private Camera camera;
	private EventManager eventManager;
	
	public CameraLODControl(){}
	
	public CameraLODControl(Camera camera, EventManager eventManager){
		this.camera = camera;
		this.eventManager = eventManager;
	}
	
	public Camera getCamera() {
		return this.camera;
	}
	
	public void setCamera(Camera camera) {
		this.camera = camera;
	}
	
	public Control cloneForSpatial(Spatial spatial) {
		CameraLODControl control = new CameraLODControl(camera, eventManager);
		control.setSpatial(spatial);
		control.setEnabled(isEnabled());
		return control;
	}

	@Override
	protected void controlUpdate(float tpf) {		
		Vector3f location = camera.getLocation();
		
		if (location.z < 5.0f) {
			//eventManager.queueEvent(new ChangeViewEvent());
		}
		
	}

	@Override
	protected void controlRender(RenderManager rm, ViewPort vp) {
		//Nothing to do
		
	}

}
